<?php
/*
*   专题列表页
*/
  $special_categories=get_terms('topic',array('hide_empty'=> false,'orderby'=>'id','order'=>'ASC',));
  get_header();
  if(have_posts()):the_post();
?>
  <div class="pinpaiMenu po_r swiper-container">
        <ul class="menuScroll_lists  po_a cf swiper-wrapper">
          <li class="swiper-slide"><a href="/" >首页<em></em></a></li>
          <?php
            foreach ($special_categories as $key => $value) {
          ?>
          <li class="swiper-slide <?php if($value->term_id == $term_detail->term_id){echo 'active';}?>"><a href="<?php echo get_term_link((int)($value->term_id),$value->taxonomy);?>" ><?php echo $value->name;?><em></em></a></li>
          <?php
            }
          ?>
        </ul>
  </div>
	<div class="listYh">
      <div class="yhBox">
          <?php
            $paged_view = $_GET['paged_view']?$_GET['paged_view']:1;//判断是否首次加载页面
            $args=array(
              'post_type' => 'special',
              'meta_key' => 'rank',
              'orderby'  => array('meta_value_num' => 'DESC', 'date' => 'DESC'),
              'posts_per_page' =>8,
              'paged' =>$paged_view
            );
            $query = new WP_Query($args);
            while($query->have_posts()):$query->the_post();
          ?>
          <div class="yhDet">
            <a href="<?php the_permalink();?>">
            <div class="yhpic po_r">
              <img class="w100" src="<?php the_field('img');?>" />
            </div>
            <div class="con cf">
              <div class="conTit float_l"><?php the_title();?></div>
            </div>
            </a>
          </div>
          <?php
            endwhile;
            wp_reset_query();
          ?>
      </div>
  </div>
  <div style="clear:both;"></div>
  <div class="post_next">加载更多</div>

<script type="text/javascript">
jQuery(document).ready(function($) {
  //点击下一页的链接(即那个a标签)   
  var paged_view=2;
  $('.post_next').click( function() {   
    $this = $(this);
    $this.html("Loading...");
    $.ajax( { //发起ajax请求   
        url: "?action=json&paged_view="+paged_view, //请求的地址就是下一页的链接   
        type: "get", //请求类型是get   
     error: function(request) {   
         //如果发生错误怎么处理   
     },   
     success: function(data) { //请求成功
        if(paged_view<=<?php echo $query->max_num_pages;?>){
          var $res = $(data).find(".yhDet"); //从数据中挑出文章数据，请根据实际情况更改   
          $('.yhBox').append($res); //将数据加载加进posts-loop的标签中。
          $this.html("加载更多");
          paged_view++;
        }else{
          $('.post_next').html("没有更多内容了");
        }
     }   
     });  
   });      
 });  
</script>
<?php
  endif;
  get_footer();
?>